package com.woniuxy.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author: 马宇航
 * @Todo: 配置死信交换机和死信队列
 * @DateTime: 25/09/01/星期一 12:14
 * @Component: 成都蜗牛学苑
 **/
@Configuration
public class DeathMQConfig {
    @Bean
    public Queue deathQueue(){
        return new Queue("order.dlx.outtime.queue");
    }
    //长度超出后的队列的处理方案
    @Bean
    public Queue lengthQueue5(){
        return new Queue("order.dlx.cancel");
    }
    @Bean
    public DirectExchange directExchangeDeath(){
        return new DirectExchange("order.dlx.outime.nopay");
    }
    //和业务中的 x-dead-letter-routing-key配置一致
    @Bean
    public Binding bindingDeathQueue(){
        return BindingBuilder.bind(deathQueue()).to(directExchangeDeath()).with("order.dlx");
    }
    //长度超出后的队列的处理方案
    @Bean
    public Binding bindingLengthQueue5(){
        return BindingBuilder.bind(lengthQueue5()).to(directExchangeDeath()).with("order.dlx.cancel");
    }
}
